/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.citi.dahg.cve;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author dh90940
 */
public abstract class BasicManagedBean {
    
    
    public void addInfo(String msg) {
        addMessage(msg, FacesMessage.SEVERITY_INFO);
    }
    
    public void addWarning(String msg) {
        addMessage(msg, FacesMessage.SEVERITY_WARN);
    }
    
    public void addError(String msg) {
        addMessage(msg, FacesMessage.SEVERITY_ERROR);
    }
    
    private void addMessage(String msg, FacesMessage.Severity severity) {
        FacesMessage message = new FacesMessage(severity, msg, msg);
        getFacesContext().addMessage(null, message);
    }
    
    private FacesContext getFacesContext() {
        return FacesContext.getCurrentInstance();
    }
}
